<template>
    <el-row justify="center">
        <el-col>
            <el-card>
                <el-form :model="form" label-width="auto">
                    <el-form-item label="机器人名称">
                        <el-input v-model="form.name" />
                    </el-form-item>
                    <el-form-item label="是否开启">
                        <el-switch v-model="form.is_open" active-value="1" inactive-value="0"/>
                    </el-form-item>
                    <el-form-item label="是否开启私聊">
                        <el-switch v-model="form.is_open_private" active-value="1" inactive-value="0"/>
                    </el-form-item>
                    <el-form-item label="开启群聊列表">
                        <el-input v-model="form.group_greeting" type="textarea" />
                    </el-form-item>
                    <el-form-item label="加群欢迎语">
                        <el-input v-model="form.group_greeting" type="textarea" />
                    </el-form-item>
                    <el-form-item label="退群提示语">
                        <el-input v-model="form.group_exit_msg" type="textarea" />
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSubmit">保存</el-button>
                    </el-form-item>
                    <el-form-item>
                        <el-text type="danger">
                            提示语可用标签  
                            <template v-for="val,key in tags" :key="key">
                                {{ val }} <el-tag type="primary" style="cursor: pointer;" @click="copyText(`\{${key}\}`)">{{ `\{${key}\}` }}</el-tag> &nbsp;
                            </template>
                            
                        </el-text>
                    </el-form-item>
                </el-form>
            </el-card>
        </el-col>


    </el-row>

</template>

<script setup>

import { ref } from 'vue'
import { getSettingConfig,setSettingConfig } from '@/apis/setting'
import { copyText } from '@/util/common'

const form = ref({})

getSettingConfig().then((data)=>{
    form.value = data
})

const onSubmit = () => {
    setSettingConfig(form.value)
}

const tags = {
    count : "群数量",
    time : "当前时间",
    nickname : "群员昵称",
    user_id : "群员QQ"
}

</script>